<template>
  <div class="header_container">
    <el-breadcrumb separator="/">
      <div class="logo-box">
        <div class="logo">
        </div>
      </div>
      <!-- <el-breadcrumb-item :to="{ path: '/manage' }">首页</el-breadcrumb-item> -->
      <!-- <el-breadcrumb-item v-for="(item, index) in $route.meta" :key="index">{{item}}</el-breadcrumb-item> -->
    </el-breadcrumb>
    <el-dropdown
      @command="handleCommand"
      placement='start'
    >
      <span class="el-dropdown-link">
        {{userName}}
        <i class="el-icon-arrow-down el-icon--right"></i>
      </span>
      <!-- <img :src="baseImgPath + adminInfo.avatar" class="avator"> -->
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="changePassword">修改密码</el-dropdown-item>
        <el-dropdown-item command="singout">退出</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
import { signout } from "@/api/getData";
import { baseImgPath } from "@/config/env";
import { mapActions, mapState } from "vuex";
import { getStore } from "../config/mUtils";
import logo from "@/assets/image/youmi_logo.png";

export default {
  data() {
    return {
      baseImgPath,
      userName: ""
    };
  },
  created() {
    // if (!this.adminInfo.id) {
    //   this.getAdminData();
    // }
    this.userName = getStore("userName");
  },
  // computed: {
  //   ...mapState(["adminInfo"])
  // },
  methods: {
    // ...mapActions(["getAdminData"]),
    async handleCommand(command) {
      if (command == "home") {
        this.$router.push("/manage");
      } else if (command == "singout") {
        const res = await signout();
        if (res.status == 200) {
          this.$message({
            type: "success",
            message: "退出成功"
          });
          this.$router.push("/");
        } else {
          this.$message({
            type: "error",
            message: res.msg
          });
        }
      } else if (command == "changePassword") {
        this.$router.push("/changePassword");
      }
    }
  }
};
</script>

<style lang="less">
@import "../style/mixin";
.header_container {
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid #dcdfe6;
}
.avator {
  .wh(36px, 36px);
  border-radius: 50%;
  margin-right: 37px;
}
.el-dropdown-menu__item {
  text-align: center;
}
.el-dropdown-link {
  color: #909399;
}
.logo-box {
  display: flex;
  align-items: center;
}
.logo {
  width: 130px;
  height: 56px;
  background: url("~@/assets/image/youmi_logo.png") no-repeat;
}
</style>
